home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
HyperCard Goodies
/
Serial Toolkit
/
Source Code
/
closeSPort.p
< prev
next >
Wrap
Text File
|
1988-11-18
|
2KB
|
98 lines
(*
closeSPort -- Close the serial port driver, and release any buffer space associated with the input.
To compile and link this file using Macintosh Programmer's Workshop,
pascal -w closeSPort.p
link -m ENTRYPOINT -o HyperCommands -rt XCMD=7031 -sn Main=closeSPort ∂
closeSPort.p.o "{MPW}"Libraries:interface.o
© Copyright 1987,88 by Apple Computer, Inc.
Initial coding 9/87 by Harry R. Chesley.
*)
{$R-}
{$S closeSPort } { Segment name must be the same as the command name. }
unit DummyUnit;
interface
uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
procedure EntryPoint(paramPtr: XCmdPtr);
implementation
type
Str31 = String[31];
procedure closeSPort(paramPtr: XCmdPtr); forward;
procedure EntryPoint(paramPtr: XCmdPtr);
begin
closeSPort(paramPtr);
end;
procedure closeSPort(paramPtr: XCmdPtr);
var i: integer;
{$I XCmdGlue.inc}
procedure Fail(errMsg: Str255); { set theResult and quit }
begin
paramPtr^.returnValue := PasToZero(errMsg);
exit(closeSPort);
end;
{$I SPortUtil.inc}
begin
if paramPtr^.paramCount <> 0 then Fail('parameter count is not 0');
SetUpSPortGlobals;
if not ThisSPort.isOpen then Fail('port is not open');
{ Wait for the output to drain. (If he didn't want to wait, he should have done a killSPort first.) }
WaitForAllFree;
{ If there's an input buffer allocated, deallocate it. }
if ThisSPort.inputBuffer <> nil then
begin
if SerSetBuf(ThisSPort.portInDev,nil,0) <> noErr then Fail('SerSetBuf failed');
DisposPtr(ThisSPort.inputBuffer);
end;
{ Dispose of all the output parmBlks. }
for i := 1 to MAXPARMBLKS do
begin
if ThisSPort.parmBlks[i]^.ioBuffer <> nil then DisposPtr(ThisSPort.parmBlks[i]^.ioBuffer);
DisposPtr(Ptr(ThisSPort.parmBlks[i]));
end;
{ Reset everything to the default values and mark the port as closed. }
with Globals^^.ports[Globals^^.selectedPort] do
begin
{ Set the default byte format. }
byteConfig := baud1200+stop10+noParity+data8;
{ Set the rest of the port defaults. }
with shakes do
begin
fXOn := 0; fCTS := 0; errs := 0; evts := 0; fInX := 0;
end;
{ Set no auto-linefeed, no echo, no edit, no strip top bits. }
sendLFs := false;
doEcho := false;
doEdit := false;
stripIncoming := true;
autoWrap := false;
currentColumn := 1;
isOpen := false;
end;
end;
end.